<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<uni-nav-bar 
			title="设备详情" 
			:border="false"
			:fixed="true"
			:status-bar="true"
			background-color="#4980FF"
			color="#FFFFFF"
			left-icon="back"
			@clickLeft="goBack">
		</uni-nav-bar>
		
		<!-- 审批列表 -->
		<scroll-view class="list" scroll-y>
			<!-- 审批详情 -->
			<view class="particulars">
				<uni-card v-for="(item, index) in approvalDetails" :key="index" :is-shadow="true" :is-full="true">
					<view class="particulars-item">
						<view class="particulars-title">{{ item.title }}</view>
						<view class="particulars-content">
							{{ item.content }}
						</view>
					</view>
				</uni-card>
			</view>
			
			<!-- 审批流程 -->
			<view class="flowChart">
				<uni-section title="流程" type="line">
					<view class="flow-list">
						<view class="flow" v-for="(flow, index) in approvalFlows" :key="index">
							<view class="icon">
								<uni-icons :type="flow.icon" size="20" :color="flow.color"></uni-icons>
							</view>
							<view class="flowTitle">
								<view class="process">
									<view class="approve">
										{{ flow.action }}
									</view>
									<view class="approveTime">
										{{ flow.time }}
									</view>
								</view>
								<view class="approver">
									<view class="approver-name">
										{{ flow.approver }}
									</view>
									<view class="approve-state">
										<uni-tag :text="flow.status" :type="flow.statusType" size="small"></uni-tag>
									</view>
								</view>
							</view>
						</view>
					</view>
				</uni-section>
			</view>
		</scroll-view>
		
		<!-- 审批按钮 -->
		<view class="approve-but">
			<uni-button 
				type="primary" 
				size="large" 
				@click="redirect"
				:custom-style="{ backgroundColor: '#4980FF', borderColor: '#4980FF', borderRadius: '45rpx' }">
				审批
			</uni-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				approvalDetails: [
					{ title: '合约部意见', content: '同意申请' },
					{ title: '所属项目', content: '天顺路桥项目' },
					{ title: '所属合同', content: 'HT-2024-001' },
					{ title: '周期类型', content: '月度' },
					{ title: '周期序号', content: '2024-04' },
					{ title: '周期名称', content: '2024年4月' },
					{ title: '开始日期', content: '2024-04-01' },
					{ title: '结束日期', content: '2024-04-30' },
					{ title: '计量月份', content: '2024年4月' }
				],
				approvalFlows: [
					{ action: '发起申请', time: '2024-04-12', approver: '张三', status: '已完成', statusType: 'success', icon: 'paperplane', color: '#4ECDC4' },
					{ action: '部门审核', time: '2024-04-13', approver: '李四', status: '已完成', statusType: 'success', icon: 'checkmarkempty', color: '#4ECDC4' },
					{ action: '财务审核', time: '2024-04-14', approver: '王五', status: '进行中', statusType: 'warning', icon: 'gear', color: '#FFA500' },
					{ action: '总经理审批', time: '待处理', approver: '赵六', status: '待处理', statusType: 'error', icon: 'person', color: '#FF6B6B' },
					{ action: '合同签署', time: '待处理', approver: '系统', status: '待处理', statusType: 'error', icon: 'locked', color: '#FF6B6B' },
					{ action: '流程完成', time: '待处理', approver: '系统', status: '待处理', statusType: 'error', icon: 'checkmarkempty', color: '#FF6B6B' }
				]
			};
		},
		methods:{
			goBack(){
				uni.navigateBack()
			},
			redirect(){
				uni.navigateTo({
					url:'/pages/examineApprove/index'
				})
			}
		}
	}
</script>

<style lang="less">
	.container {
		flex: 1;
		background-color: #E6EAF3;
		padding-top: 88px;
	}
	
	.list{
		flex: 1;
		padding: 10px;
	}
	
	.particulars{
		margin-bottom: 18rpx;
	}
	
	.particulars-item{
		flex-direction: row;
		padding: 32rpx 32rpx;
		font-family: PingFang SC;
		font-size: 32rpx;
		font-weight: normal;
		line-height: 48rpx;
		color: rgba(0, 0, 0, 0.9);
		border-bottom: 1rpx solid #E7E7E7;
		background-color: #FFF;
		display: flex;
	}
	
	.particulars-title{
		width: 162rpx;
		margin-right: 32rpx;
		font-weight: 500;
	}
	
	.particulars-content{
		flex: 1;
		color: #666;
	}
	
	.flowChart{
		background-color: #fff;
		margin-bottom: 30rpx;
		border-radius: 12rpx;
		overflow: hidden;
	}
	
	.flow-list{
		padding: 0 32rpx;
	}
	
	.flow{
		flex-direction: row;
		display: flex;
		align-items: flex-start;
		padding: 30rpx 0;
		border-bottom: 1rpx solid #E7E7E7;
	}
	
	.flow:last-child{
		border-bottom: none;
	}
	
	.icon{
		width: 88rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.flowTitle{
		flex: 1;
		padding-right: 24rpx;
		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: normal;
		line-height: 44rpx;
	}
	
	.process{
		flex-direction: row;
		justify-content: space-between;
		display: flex;
		margin-bottom: 8rpx;
	}
	
	.approver{
		flex-direction: row;
		justify-content: space-between;
		display: flex;
		align-items: center;
	}
	
	.approve{
		font-weight: 500;
		color: #333;
	}
	
	.approveTime{
		color: #999;
		font-size: 24rpx;
	}
	
	.approver-name{
		color: #666;
		font-size: 24rpx;
	}
	
	.approve-state{
		display: flex;
		align-items: center;
	}
	
	.approve-but{
		position: fixed;
		bottom: 60rpx;
		left: 84rpx;
		width: 580rpx;
		height: 90rpx;
		z-index: 100;
	}
</style>
